package br.edu.ifrn.generic;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.MappedSuperclass;

import br.edu.ifrn.exception.NegocioException;

@MappedSuperclass
public abstract class GenericEntidade {

    public abstract Serializable getId();

    @Override
    public abstract int hashCode();

    @Override
    public abstract boolean equals(Object object);
    
    public abstract boolean isNewRecord();
    
    @Override
    public String toString() {
        return this.getClass().getSimpleName();
    }
    
    public void validar() throws NegocioException{
		List<String> erros = new ArrayList<String>();
		
		validarImpl(erros);
		
		if(!erros.isEmpty()) {
			throw new NegocioException(erros);
		}    
	}
    
    public abstract void validarImpl(List<String> erros);
    

}